<template>
    功能测试页面
    <div id="result">

    </div>
    <br />
    <el-button @click="requestTest">多服务请求测试</el-button>
</template>

<script  setup>
// import { onMounted, onUnmounted } from 'vue';
// import { userTestService } from '@/api/user.js';
// import { propertyTestService } from '@/api/property.js';
// import { workorderTestService } from '@/api/workorder.js';
// import { patrolTestService } from '@/api/patrol.js';
// import { logandmsgTestService } from '@/api/logandmsg.js';

// console.log('currentUser:' + localStorage.getItem('id') + localStorage.getItem('role'))
// let socket = new WebSocket('ws://localhost:8081/websocket/' + localStorage.getItem('id'));

// const connect = () => {

//     socket.onopen = () => {
//         console.log('WebSocket connection established.');
//         sendMessageToServer('来自前端的反馈：连接成功')
//     };

//     socket.onmessage = (event) => {
//         const message = event.data;
//         console.log('Received message:', message);
//         // 在这里处理收到的通知消息
//         // 获取目标div元素
//         var resultDiv = document.getElementById('result');

//         // 创建新的子组件（这里是<p>元素）
//         var newComponent = document.createElement('p');
//         newComponent.textContent = message;

//         // 将新创建的子组件添加到结果div中
//         resultDiv.appendChild(newComponent);
//     };

//     socket.onerror = (error) => {
//         console.error('WebSocket error:', error);
//     };

//     socket.onclose = () => {
//         console.log('WebSocket connection closed.');
//         // 可能需要重新连接
//     };
// };

// function sendMessageToServer(message) {
//     if (socket.readyState === WebSocket.OPEN) {
//         socket.send(message);
//         console.log('Sent message:', message);
//     } else {
//         console.log('WebSocket connection not open. Cannot send message.');
//     }
// }

// const requestTest = async () => {
//     const userResult = await userTestService();
//     const propertyResult = await propertyTestService();
//     const workorderResult = await workorderTestService();
//     const patrolResult = await patrolTestService();
//     const logandmsgResult = await logandmsgTestService();

//     console.log(userResult);
//     console.log(propertyResult);
//     console.log(workorderResult);
//     console.log(patrolResult);
//     console.log(logandmsgResult);

// }


// // 该组件被渲染时调用
// onMounted(() => {
//     connect();
// })

// // 组件卸载时断开连接
// onUnmounted(() => {
//     if (socket && socket.readyState !== WebSocket.CLOSED) {
//         socket.close();
//     }
// });
</script>

<style></style>